package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class SolverChooser extends JFrame {
	public static SolverChooser sa = new SolverChooser();
	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SolverChooser frame = new SolverChooser();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SolverChooser() {
		setUndecorated(true);
		setBounds(100, 100, 199, 357);
		contentPane = new JPanel();
		contentPane.setBorder(new TitledBorder(null, "Numerical Beast", TitledBorder.CENTER, TitledBorder.ABOVE_TOP, null, null));
		contentPane.setBackground(Color.lightGray);
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		
		
		JButton btnNewButton = new JButton("General Algorihm");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Solver.sol = new Solver("");
				setVisible(false);
				Solver.sol.setVisible(true);
				Main.main.setVisible(false);
			}
		});
		btnNewButton.setBounds(20, 37, 158, 46);
		contentPane.add(btnNewButton);
		
		JButton btnBisection = new JButton("Bisection");
		btnBisection.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Solver.sol = new Solver("b");
				setVisible(false);
				Solver.sol.setVisible(true);
				Main.main.setVisible(false);
			}
		});
		btnBisection.setBounds(20, 94, 158, 46);
		contentPane.add(btnBisection);
		
		JButton btnNewtonraphson = new JButton("Newton-Raphson");
		btnNewtonraphson.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Solver.sol = new Solver("n");
				setVisible(false);
				Solver.sol.setVisible(true);
				Main.main.setVisible(false);
			}
		});
		btnNewtonraphson.setBounds(20, 232, 158, 46);
		contentPane.add(btnNewtonraphson);
		
		JButton btnFalseposition = new JButton("False-position");
		btnFalseposition.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Solver.sol = new Solver("f");
				setVisible(false);
				Solver.sol.setVisible(true);
				Main.main.setVisible(false);
			}
		});
		btnFalseposition.setBounds(20, 162, 158, 46);
		contentPane.add(btnFalseposition);
		
		JButton btnSecant = new JButton("Secant");
		btnSecant.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Solver.sol = new Solver("s");
				setVisible(false);
				Main.main.setVisible(false);
				Solver.sol.setVisible(true);
			}
		});
		btnSecant.setBounds(20, 300, 169, 46);
		contentPane.add(btnSecant);
	}

}
